public class Solution520 {
    public boolean detectCapitalUse(String word) {
        int t=0;
        for (int i=0;i<word.length();i++){
            if (word.charAt(i)>='a' && word.charAt(i)<='z'){
                t++;
            }
        }
        if (t==word.length() || t==0){
            return true;
        }
        if (t==word.length()-1 && word.charAt(0)>='A' && word.charAt(0)<='Z'){
            return true;
        }
        return false;
    }

    public static void main(String[] args) {
        System.out.println(new Solution520().detectCapitalUse("FlaG"));
    }
}
